$(function () {
    let form = layui.form;
    let layer = layui.layer;
    form.verify({
        pass: [
            /^[\S]{6,12}$/
            , '密码必须6到12位，且不能出现空格'
        ],
        repass: function (value) {
            if (value != $('[name=newPwd]').val()) {
                return "两次密码不一致"
            }
        }
    });

    $('form').on('submit', function (e) {
        e.preventDefault();
        $.ajax({
            method: 'post',
            url: '/my/updatepwd',
            data: $(this).serialize(),
            success(res) {
                console.log(this);
                if (res.status != 0) {
                    layer.msg(res.message, { icon: 2 })
                }  else {
                    layer.msg(res.message, { icon: 1 })
                    $('[type=reset]').click()
                }
            }
        })
    })
})